#include <iostream>

// include nyu header
#include <nyu/nyu.hpp>

// user defined function
nyu::Value cpp_func(nyu::Context& c) {
    std::cout << __FUNCTION__ << std::endl;

    return nyu::NULL_VALUE;
}

int main() {
    // create context
    nyu::Context c;

    // register cpp_func
    c.putFunction("cpp_func", cpp_func);

    // execute script
    nyu::Handle<nyu::Value> v(c.evalString("nyu_func = {% cpp_func(); %}; 0"));

    // get symbol
    nyu::Value nyu_func = c.getSymbol("nyu_func");
    if (!nyu::is_object(nyu_func) || nyu::is_null(nyu_func)) {
        std::cerr << "cannot get nyu_func..." << std::endl;
        return 1;
    }

    // call nyu_func
    nyu::Handle<nyu::Value> ret(c.call(nyu_func));

    return 0;
}
